//
//  DHBaseController.m
//  精品酒店
//
//  Created by DIANGHONG on 2018/5/7.
//  Copyright © 2018年 DIANGHONG. All rights reserved.
//

#import "DHBaseController.h"
#import "JPWebViewController.h"
@interface DHBaseController () <UITableViewDelegate, UITableViewDataSource,UITabBarControllerDelegate>
@property(nonatomic,strong)NSString *strUrl;
@property(nonatomic,strong)JPWebViewController *webViewVC;
@property(nonatomic,strong)UIButton *button;
@end

@implementation DHBaseController
// 表格视图懒加载
- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc] init];
    }
    return _tableView;
}




- (void)viewDidLoad {
    [super viewDidLoad];

    self.tabBarController.delegate = self;
    [self setupUI];
    
    [self shouldLogWeb];
    
    self.button = [[UIButton alloc] initWithFrame:CGRectMake(20, self.tabBarController.tabBar.frame.origin.y - 100
                                                             , 40, 40)];
    [self.button addTarget:self action:@selector(goToJPWeb) forControlEvents:UIControlEventTouchUpInside];
  
    [self.button setImage:[UIImage imageNamed:@"icon_con"] forState:UIControlStateNormal];
    [self.view addSubview:self.button];
}

- (void)shouldLogWeb{
    self.strUrl = @"http://jpjd.cnaite.cn/wap";
    
    self.webViewVC = [[JPWebViewController alloc] init];
    self.webViewVC.urlStr = self.strUrl;
    [self.navigationController presentViewController:self.webViewVC animated:true completion:nil];
}

- (void)goToJPWeb{
    self.strUrl = @"http://jpjd.cnaite.cn/wap";
    self.webViewVC = [[JPWebViewController alloc] init];
    self.webViewVC.urlStr = self.strUrl;
    [self.navigationController presentViewController:self.webViewVC animated:true completion:nil];
}
- (void)setupUI{
    
[self setupTableView];
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString * status = [user objectForKey:@"isLogOut"];
    
//    if ([status isEqualToString:@"1"]) {
//        self.tabBarController.selectedIndex = 1;
//        [user setObject:@"0" forKey:@"isLogOut"];
//        [user synchronize];
//    }else{
//        self.tabBarController.selectedIndex = 0;
//        
//        
//    }
    //self.tabBarController.delegate = self;
}

- (void)setupTableView{
   // self.tableView.backgroundColor = [UIColor randomColor];
    self.tableView.frame = self.view.bounds;
    [self.view addSubview:self.tableView];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
    self.tabBarController.tabBar.hidden = false;


}



#pragma mark: - UITableViewDelegate UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    return [[UITableViewCell alloc] init];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 10;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{
   
    
}

@end
